/*
   Copyright (c) 2023 李伟国
   learner-platform is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2. 
   You may obtain a copy of Mulan PSL v2 at:
               http://license.coscl.org.cn/MulanPSL2 
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
   See the Mulan PSL v2 for more details. 
*/

package cn.platform.controller;

import cn.platform.entity.AlgorithmSet;
import cn.platform.response.ResponseData;
import cn.platform.response.SuccessResponseData;
import cn.platform.service.IAlgorithmSetService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("algorithm/set")
public class AlgorithmSetController extends BaseController{
    //---------------------------------
    @Autowired
    private IAlgorithmSetService algorithmSetService;

    // 创建题目集
    @RequestMapping(value = "", method = RequestMethod.POST)
    public ResponseData createSet(AlgorithmSet algorithmSet){
        boolean algorithmSet1 = algorithmSetService.createAlgorithmSet(algorithmSet);
        return new SuccessResponseData(algorithmSet1);
    }
    // 题目集列表
    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResponseData setList(@RequestParam(required = false) String name,
                                @RequestParam(required = false) String status,
                                @RequestParam(required = false) Long userId){
        Page<AlgorithmSet> algorithmSetPage = algorithmSetService.algorithmSetList(name, status, userId);
        return new SuccessResponseData(algorithmSetPage);
    }
    // 删除题目集
    @RequestMapping(value = "", method = RequestMethod.DELETE)
    public ResponseData delete(AlgorithmSet algorithmSet){
        boolean b = algorithmSetService.deleteAlgorithmSet(algorithmSet);
        return new SuccessResponseData(b);
    }
    // 发布题目集
    @RequestMapping(value = "/release", method = RequestMethod.POST)
    public ResponseData release(AlgorithmSet algorithmSet){
        boolean b = algorithmSetService.releaseAlgorithmSet(algorithmSet);
        return new SuccessResponseData(b);
    }
    // 停用题目集
    @RequestMapping(value = "lock", method = RequestMethod.POST)
    public ResponseData lock(AlgorithmSet algorithmSet){
        boolean b = algorithmSetService.lockAlgorithmSet(algorithmSet);
        return new SuccessResponseData(b);
    }
    // 更新题目集
    @RequestMapping(value = "", method = RequestMethod.PUT)
    public ResponseData update(AlgorithmSet algorithmSet){
        boolean b = algorithmSetService.updateById(algorithmSet);
        return new SuccessResponseData(b);
    }
    //---------------------------------

    // 发送竞赛邮件

    // 发送竞赛公告

    // 用户自己订阅的题目集

    //---------------------------------



}
